<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isELIgnored="false"%>
<%@include file="/resources/common/commonTaglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- 导入资源文件 -->
<%@include file="/resources/common/commonJs.jsp" %>
<%@include file="/resources/common/commonCss.jsp" %>
<script src="${path }/resources/zui-1.6.0/lib/chart/zui.chart.js"></script>
<title>我的成绩信息</title>
<script type="text/javascript">

//构造学生成绩list
var courseArr = ["语文", "数学", "英语", "化学", "物理", "历史", "政治"];
var resultVals = JSON.parse('${resultVals}');
var totalSocreArr = [0, 0, 0, 0, 0, 0, 0], objectiveItemValArr = [0, 0, 0, 0, 0, 0, 0], subjectiveItemValArr = [0, 0, 0, 0, 0, 0, 0];
for (var i = 0, len = resultVals.length; i < len; i++) {
	var val = resultVals[i];
	//获取科目, 进行判断
	switch (val.courseType.courseName) {
		case '语文':
			totalSocreArr[0] = val.scoreTotalVal;
			objectiveItemValArr[0] = val.objectiveItemVal;
			subjectiveItemValArr[0] = val.subjectiveItemVal;
			break;
		case '数学':
			totalSocreArr[1] = val.scoreTotalVal;
			objectiveItemValArr[1] = val.objectiveItemVal;
			subjectiveItemValArr[1] = val.subjectiveItemVal;
			break;
		case '英语':
			totalSocreArr[2] = val.scoreTotalVal;
			objectiveItemValArr[2] = val.objectiveItemVal;
			subjectiveItemValArr[2] = val.subjectiveItemVal;
			break;
		case '化学':
			totalSocreArr[3] = val.scoreTotalVal;
			objectiveItemValArr[3] = val.objectiveItemVal;
			subjectiveItemValArr[3] = val.subjectiveItemVal;
			break;
		case '物理':
			totalSocreArr[4] = val.scoreTotalVal;
			objectiveItemValArr[4] = val.objectiveItemVal;
			subjectiveItemValArr[4] = val.subjectiveItemVal;
			break;
		case '历史':
			totalSocreArr[5] = val.scoreTotalVal;
			objectiveItemValArr[5] = val.objectiveItemVal;
			subjectiveItemValArr[5] = val.subjectiveItemVal;
			break;
		case '政治':
			totalSocreArr[6] = val.scoreTotalVal;
			objectiveItemValArr[6] = val.objectiveItemVal;
			subjectiveItemValArr[6] = val.subjectiveItemVal;
			break;
	}
}
var data = {
	    labels: courseArr,
	    datasets: [
	        {
	            label: "总分",
	            color: 'primary',
	            data: totalSocreArr
	        }, {
	            label: "客观题",
	            color: 'green',
	            data: objectiveItemValArr
	        }, {
	            label: "主观题",
	            color: 'blue',
	            data: subjectiveItemValArr
	        }
	    ]
	};

$(function() {
	//全选/全不选
	$('#quanxuan').click(function() {
		var checkStatus = $(this).attr('checked');
		var $quanxuan = $('input[name="quanxuan"]');
		if (checkStatus) {
			$quanxuan.attr('checked', true);
		} else {
			$quanxuan.attr('checked', false);
		}
	});
	var options = {responsive: true}; // 图表配置项，可以留空来使用默认的配置
	var myBarChart = $('#myChart').barChart(data, options);
})
</script>
</head>
<body>
<div>
	<!-- 学生成绩基本信息start -->
	<div class="listDataTableStyle">
	<table cellpadding="0" cellspacing="0" width="100%">
		<tr>
			<th colspan="4">个人基本信息</th>
		</tr>
		<tr>
			<td>学生姓名</td>
			<td>${sessionUser.name }</td>
			<td>学生班级</td>
			<td>${sessionUser.studentClass.className }</td>
		</tr>
		<tr>
			<td>考场</td>
			<td>${sessionUser.examPlace.examPlaceName }</td>
			<td>年级</td>
			<td>${sessionUser.studentClass.gradeName }</td>
		</tr>
		<tr>
			<td>总分</td>
			<td>${stuScoreAndRank.totalScore }</td>
			<td>年级排名</td>
			<td>${stuScoreAndRank.studentRank }名</td>
		</tr>
		<tr>
		</tr>
	</table>
	</div>
	<!-- 学生成绩基本信息end -->
	
	<!-- 学生成绩分析图表start -->
	<div >
		<div style="width: 90%; margin-left: 5%; text-align: center;">学生成绩详情</div>
		<canvas id="myChart" width="320" height="120"></canvas>
	</div>
	<!-- 学生成绩分析图表end -->
</div>

</body>
</html>